package com.learner.course.controller.admin;

import com.learner.course.service.CourseBaseService;
import com.learner.pojo.course.CourseBase;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author ice2020x
 * @Date 2022-06-15 3:07
 * @Description:
 */
@Slf4j
@RestController
@RequestMapping("/admin/edu/course")
public class CourseBaseController {

    @Autowired
    CourseBaseService courseBaseService;

    /**
     * @Description: 保存基础课程信息的接口
     * @Author: ice2020x
     * @Date: 2021/10/13
     */
    @PostMapping("/course_info/save/info")
    public CourseBase saveCourseInfo(@RequestBody CourseBase courseInfo) {
        log.info("保存基础课程信息的接口,{}", courseInfo);
        return courseBaseService.saveCourseBase(courseInfo);

    }

    /**
     * 根据id查询课程信息
     *
     * @param courseId 课程id
     * @return 结果
     */
    @GetMapping("/course_info/get/{id}")
    public CourseBase getCourseBaseById(@PathVariable("id") String courseId) {
        return  courseBaseService.getCourseBaseById(courseId);
    }

    /**
     * 根据id修改课程信息
     * @param id 课程id
     * @param courseBase 课程信息
     * @return 结果
     */
    @PutMapping("/course_info/update/{id}")
    public CourseBase updateCourseBase(@PathVariable("id") String id, @RequestBody CourseBase courseBase) {
        return courseBaseService.updateCourseBase(id, courseBase);
    }


}
